Дан массив из строчных латинских букв. Вывести на экран в алфавитном порядке все буквы, которые входят в этот текст по одному разу — C++(Си)

#include <stdio.h>
 
const int alph_length = 26;
 
 
int main() {
    int i;
    char text[81];
    char *p;
 
    int letters_encountered[alph_length];
 
    for(i = 0;i< alph_length ; i++ ) 
         letters_encountered[i]=0;
 
    fgets(text,80,stdin);
 
    p = text;
 
    while(*p!=0) {
        if(*p< 'a' || *p > 'z') {
 
            p++;
            continue;
        };
 
        letters_encountered[*(p++) -'a']++;
    };
 
    for(i=0;i<alph_length;i++) { 
        if(letters_encountered[i]==1)
            printf("%c",'a'+(char)i);
 
    };
    return 0;
 
};

Следующий вариант

#include<stdio.h>
 
int Comp(const void* a, const void* b){
    return *(char*)a-*(char*)b;
}
 
int main(){
    char text[]="fghbnggnawqxw", *p=text;
    qsort(text, sizeof(text)-1, sizeof(*text), Comp);
    for(; *p; ++p){
        if(*p==*(p+1)){
            while(*p==*(p+1))++p;
        }
        else{
            printf("%c", *p);
        }
    }
    return 0;
}

Следующий вариант

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
int Compare(const void* a, const void* b){
    return *(char*)a-*(char*)b;
}
 
int main(){
    char *matr[]={{"abcemn"},
                   {"fedkpo"},
                   {"ghijqr"},
                   {"xwvuts"},
                   {"yzaala"}}, res[100]={'\0'}, i, *a=res, *b=res;
    for(i=0; i<sizeof(matr)/sizeof(*matr); i++){
        strcat(res, matr[i]);
    }
    qsort(res, strlen(res), sizeof(*res), Compare);
    for(; *b=*a; ++a){
        if(*a!=*(a+1))++b;
    }
    puts(res);
    return 0;
}

20 Thoughts to “Дан массив из строчных латинских букв. Вывести на экран в алфавитном порядке все буквы, которые входят в этот текст по одному разу — C++(Си)”

  1. Wow, incredible blog format! How lengthy have you been running a blog for?
    you made blogging look easy. The whole look of your website is excellent, let alone the content!
    You can see similar here najlepszy sklep

  2. You can definitely see your skills in the work
    you write. The arena hopes for more passionate writers such as you who aren’t afraid to say how they believe.
    All the time go after your heart. I saw similar here: Dobry sklep

  3. Somebody essentially lend a hand to make severely posts I’d state. That is the very first time I frequented your website page and so far? I surprised with the research you made to make this actual put up extraordinary. Wonderful process!

  4. I love reading an article that can make men and women think.
    Also, thank you for permitting me to comment!
    I saw similar here: Sklep online

  5. It’s very interesting! If you need help, look here: ARA Agency

  6. Hey there! Do you know if they make any plugins to assist with SEO?
    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good gains.
    If you know of any please share. Thanks! You can read
    similar text here: Sklep online

  7. Hello! Do you know if they make any plugins to help with SEO?

    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good
    gains. If you know of any please share. Kudos! You can read
    similar blog here: E-commerce

  8. Informative Site… Hello guys here are some links that contains information that you may find useful yourselves. It’s Worth Checking out 급전

  9. Absolutely pent subject matter, appreciate it for selective information .대출

  10. Your passion for this topic shines through in your writing.급전

  11. I’m inspired by your dedication to this cause.급전

  12. Your writing resonates with me on a personal level. Thank you for sharing.급전

  13. Your passion for this topic shines through in your writing.대출

  14. Your article has challenged my assumptions in the best possible way.급전

  15. It’s very interesting! If you need help, look here: link building

  16. This post was exactly what I needed to read today. Thank you for sharing.급전

  17. Your article has challenged my assumptions in the best possible way.급전

  18. I found your perspective on this topic very interesting. Well done!blogpulse

  19. Great post! I learned a lot from your insights. Thank you for sharing.slotcoin

  20. You always provide such detailed and well-researched content. Thank you!pulsepeak

Leave a Comment